<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" type="text/css" href="/Public/css/global.css" />
  <script src="/Public/js/jquery-2.1.1.min.js"></script>
  <script src="/Public/js/time.js"></script>
  <script src="/Public/js/jquery.min.js"></script>
  <script src="/Public/layer/layer.js"></script>
  <script type="text/javascript">
    //表单验证
      function checklogin()
      {
          var tel= document.getElementById("txtuser").value;
          var password = document.getElementById("txtpwd").value;
          //alert(password);
          if(tel=="")
          {
              layer.alert("手机号/用户名不能为空！");
              document.getElementById("txtuser").focus();
              return false;
          }else if(!(/^1[34578]\d{9}$/.test(tel)))
          {
              layer.alert("请输入有效的手机号！");
              document.getElementById("txtuser").focus();
              return false;
          }else if(password=="")
          {
              layer.alert("密码不能为空！");
              document.getElementById("txtpwd").focus();
              return false;
          }
          $.ajax({
              type:"post",
              url:"/index.php/Home/login/log",
              data:{
                'tel':tel,
                'password':password
              },
              datatype:"json",
              success:function(data){
                if(data==0){
                    window.location.href='/index.php/home/index/index/phone/'+tel;
                }else if(data==1){
                    layer.alert('手机号/用户名不存在');
                }else if(data==2){
                    layer.alert('用户名或密码不能为空');
                }else if(data==3){
                    layer.alert('密码有误');
                }else if(data==4){
                    layer.alert('您未通过审核');
                }
              }
          });
      }

      $(function(){
          //手机号是否否存在
          $("#txtuser").blur(function(){
              var tel= document.getElementById("txtuser").value;
              $.ajax({
                  type:"post",
                  url:"/index.php/Home/login/check",
                  data:{'tel':tel},
                  datatype:"json",
                  success:function(msg){
                    //console.log(msg);
                      if(msg==1)
                      {
                          layer.alert("手机号不存在！");
                          //document.getElementById("txtuser").focus();
                      }
                  }
              });
          });
          //密码是否正确
          $("#txtpwd").blur(function(){
              var password = document.getElementById("txtpwd").value;
              $.ajax({
                  type:"post",
                  url:"/index.php/Home/login/check",
                  data:{'password':password},
                  datatype:"json",
                  success:function(msg){
                    //console.log(msg);
                    if(msg==2)
                    {
                        layer.alert("密码有误！");
                        //document.getElementById("txtpwd").focus();
                    }
                  }
              });
          });
          
      });
  </script>

</head>
<body style="background:#fff;">
<div>
  <link href="/Public/css/login.css" rel="stylesheet" type="text/css" />
  <form method="post" action="/index.php/Home/login/log" id="form1">
    <div class="aspNetHidden">
      <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="" />
    </div>
    <header id="title">
      <div class="back"> </div>
      <div class="back"><a href="javascript:void(0)" onclick="javascript:history.go(-1);return false;" ></a>  </div>
      个人登录 </header>
      <div style="height:2.8em;"></div>
    <section id="login">
      <div><span style="display:black;width:18%; overflow:hidden;"> <img src="/Public/images/icon_phone.png" width="24" height="24" alt="用户名图标"></span>
        <input style="display:black;float:left; " type="text" id="txtuser" name="txtuser" placeholder="手机号码/用户名">
      </div>
      <div> <span style="display:black; width:18%; overflow:hidden;"> <img src="/Public/images/icon_password.png" width="24" height="24" alt="密码图标"> </span>
        <input style="display:black;float:left; " id="txtpwd" name="txtpwd" type="password" placeholder="请输入密码">
      </div>
      <input  type="hidden" name="openid" value="" />
      <input type="button" onclick="return checklogin()" class="btnLogin" style="width:100%;height:3rem;background-color: #1A92DE" value="登录"><p><a href="/index.php/Home/index/register" style="float:left">注册</a><a href="/index.php/Home/login/findcode" style="float:right">忘记密码</a></p>
  </section>
  </form>
</div>
</body>
</html>
